<?php
    class Quanlytrangthaiduan_model extends CI_Model {
        function __construct() {
            parent::__construct();
            $this->load->helper('url');
            $this->load->database();
        }
        
        function getDanhSachTrangThai() {
            $query = $this->db->get("trangthaiduan");
            return $query->result();
        }
        
        function suaTrangThai($data) {
            $this->db->where('MaTrangThai', $data['MaTrangThai']);
            $this->db->update('trangthaiduan', $data);
        }
        
        function themTrangThai($data) {
            $this->db->insert('trangthaiduan', $data);
            $query = $this->db->get_where('trangthaiduan', 'MaTrangThai = LAST_INSERT_ID()');
            if($query){
                return $query->result();
            }else{
                return false;
            }
        }
        
        function xoaTrangThai($idMaTrangThai) {
            $this->db->delete('trangthaiduan', array('MaTrangThai'=>$idMaTrangThai));
        }
        
        function getTrangThai() {
            //something in here
        }
    }

?>